home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr52 / ncclib.zip / NCCDEMO.ZIP / G_DATA.PRG < prev    next >
Text File  |  1992-10-21  |  5KB  |  159 lines

  1. //═══════════════════════════════════════════════════════╕
  2. //  Program .....: G_Data                                │
  3. //  CopyRight ...: 1992 National Computer Consultants    │
  4. //                 All rights are reserved.              │
  5. //  Author ......: Greg Rice                             │
  6. //═══════════════════════════════════════════════════════╛
  7.  
  8. #include "inkey.ch"
  9. #include "dbstruct.ch"
  10.  
  11. #define BUFFER   250
  12. #define CRLF     Chr(13) + chr(10)
  13.  
  14. Function g_DataClose()
  15.  
  16.     dbCloseArea()
  17.     WinFilename( , "" )
  18.     WinIndexfiles( , {""} )
  19.     WinViewFields( , {""} )
  20.     WinViewStru( , {""} )
  21.     ShowBackGround()
  22.     OpenDesktop()
  23.  
  24. Return( NIL )
  25.  
  26.  
  27. Function g_DataOpen()
  28.  
  29.     local GetList   := {}                                       , ;
  30.           xFile     := "*.DBF" + space(13)                      , ;
  31.           sCursor   := Set(_SET_CURSOR)                         , ;
  32.           nWorkArea := Current_Window()                         , ;
  33.           sColor    := SetColor()                               , ;
  34.           cScreen   := savescreen()                             , ;
  35.           scrn      := savescreen(maxrow()-5,03,maxrow(),79)    , ;
  36.           Mouse     := MouseSys()                               , ;
  37.           nPos      := 0                                        , ;
  38.           i
  39.  
  40.  
  41.     for i = 1 to len(windows())
  42.       if empty(alias(i))
  43.         nWorkArea := i
  44.         exit
  45.       endif
  46.     next
  47.  
  48.     SetColor( popup_color() )
  49.     WinBox(maxrow()-5,03,maxrow()-2,30,0,4,.t.)
  50.     @ maxrow()-4,04 say 'Open Database Window #' get nWorkArea pict '#'
  51.     @ maxrow()-3,04 say 'File:' get xFile picture '@KS25'
  52.  
  53.     Set Cursor On
  54.     Read
  55.     Set( _SET_CURSOR, sCursor )
  56.     Setcolor( sColor )
  57.  
  58.     if lastkey() # K_ESC
  59.       if nWorkArea > 0 .and. nWorkArea < 10
  60.         While "?" $ xFile .or. "*" $ xFile
  61.           setcolor( popup_color() )
  62.           xFile := DirPick( xFile,,44 )
  63.           SetColor( sColor )
  64.         Enddo
  65.  
  66.         xFile := ltrim(trim(xFile))
  67.  
  68.         nPos := Rat( ".", xFile )
  69.  
  70.         if select(Substr(xFile,1,nPos-1)) != 0
  71.            SetColor( "W+/R" )
  72.            WinBox(9,19,15,62,,5,.t.)
  73.            @ 11,22 say 'This file is already open in a window.'
  74.            @ 13,24 say 'Click the mouse or press any key'
  75.  
  76.            Mouse:ClearButtons()
  77.            Mouse:Show()
  78.            While Mouse:Button == 0 .and. Mouse:Ascii == 0
  79.              Mouse:Update()
  80.            Enddo
  81.            Mouse:Hide()
  82.  
  83.            SetColor( sColor )
  84.  
  85.            restscreen(,,,,cScreen)
  86.  
  87.            Return( NIL )
  88.         endif
  89.  
  90.         if File( xFile ) .or. File( xFile + '.DBF' )
  91.           Sele (nWorkArea)
  92.           dbCloseArea()
  93.           WinFilename(nWorkArea , "" )
  94.           WinIndexfiles(nWorkArea , {""} )
  95.           WinViewFields(nWorkArea , {""} )
  96.           WinViewStru(nWorkArea , {""} )
  97.           Sele (nWorkArea)
  98.           if ffshare( xFile )
  99.             WinFilename(nWorkArea , uppe(ltrim(trim(xFile))) )
  100.             WinViewFields(nWorkArea , stru_load(dbstruct()) )
  101.             WinViewStru( nWorkArea, dbstruct() )
  102.             Window_Active( .t. )
  103.             Current_Window( nWorkArea )
  104.           endif
  105.         elseif ! lastkey() == K_ESC
  106.           NccMesg( 'File not Found... Press any key', 24, 'center')
  107.  
  108.           Mouse:ClearButtons()
  109.           Mouse:Show()
  110.           While Mouse:Button == 0 .and. Mouse:Ascii == 0
  111.             Mouse:Update()
  112.           Enddo
  113.           Mouse:Hide()
  114.  
  115.         endif
  116.       endif
  117.     endif
  118.     SetColor( sColor )
  119.  
  120.     restscreen(maxrow()-5,03,maxrow(),79,scrn)
  121.  
  122. Return( NIL )
  123.  
  124.  
  125.  
  126. Function g_DispStru()
  127.  
  128.     local xh := setcolor(), scrn := savescreen(), n := {}, xTop
  129.  
  130.  
  131.     AEVAL(dbstruct(),{ |fi_stru| aadd(n,space(1)+;
  132.                                       padr(fi_stru[DBS_NAME],10,' ')+ ;
  133.                                       space(5)+fi_stru[DBS_TYPE]+space(5)+;
  134.                                       str(fi_stru[DBS_LEN],3)+space(5)+ ;
  135.                                       str(fi_stru[DBS_DEC],3)+' ') })
  136.  
  137.     setColor( popup_color() )
  138.  
  139.     xTop := int(((maxrow()/2) - 4 ))
  140.  
  141.     arraydsp( n, ;
  142.              'Fieldname   Type     Len     Dec', ;
  143.              'File Structure' ;
  144.              ,xTop,21,xTop+09,55, ;
  145.              0, ;
  146.              0, ;
  147.              .t., ;
  148.              , ;
  149.              { |o| dView_MouseReader(o,xTop,21,xTop+09,55) ;
  150.              } ;
  151.             )
  152.  
  153.  
  154.     restscreen(,,,,scrn)
  155.     setcolor( xh )
  156.  
  157.  
  158. Return( NIL )
  159.